# fibonacci_generator.py

def fibonacci_generator(n):
    a, b = 0, 1
    for _ in range(n):
        yield a
        a, b = b, a + b

# 测试
n = 10
fib_sequence = list(fibonacci_generator(n))
print(f"斐波那契数列前{n}项：{fib_sequence}")